package cn.com.utt.unms.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import cn.com.utt.unms.pojo.CustomRf;

@Mapper
public interface CustomRfMapper {
	
	@Select("select * from custom_rf where device_id=#{deviceId}")
	CustomRf queryByDeviceID(@Param("deviceId") long deviceId);
	
	@Insert("insert into custom_rf(device_id,g24_en,g24_standard,g24_channel,g24_bandwidth,g24_bitrate,g24_power_mode,g24_power_level,g24_beacon_interval,g24_wmm_en,g24_romaing_en,g24_wmm_relate,g24_roaming_threshold,g24_short_interval,g24_short_preamble,g24_clients,g5_en,g5_standard,g5_channel,g5_bandwidth,g5_vht_bandwidth,g5_power_mode,g5_power_level,g5_beacon_interval,g5_wmm_en,g5_romaing_en,g5_wmm_relate,g5_roaming_threshold,g5_short_interval,g5_short_preamble,g5_clients) "
			+ "values(#{deviceId},#{g24En},#{g24Standard},#{g24Channel},#{g24Bandwidth},"
			+ "#{g24Bitrate},#{g24PowerMode},#{g24PowerLevel},#{g24BeaconInterval},#{g24WmmEn},#{g24RomaingEn},#{g24WmmRelate},#{g24Roamingthreshold},#{g24ShortInterval},#{g24ShortPreamble},#{g24Clients},"
			+ "#{g5En},#{g5Standard},#{g5Channel},#{g5Bandwidth},#{g5VhtBandwidth},#{g5PowerMode},#{g5PowerLevel},#{g5BeaconInterval},#{g5WmmEn},#{g5RomaingEn},#{g5WmmRelate},#{g5Roamingthreshold},#{g5ShortInterval},#{g5ShortPreamble},#{g5Clients})")
	void save(CustomRf deviceRf);
	
	@Update("update custom_rf set g24_en=#{g24En},g24_standard=#{g24Standard},g24_channel=#{g24Channel},g24_bandwidth=#{g24Bandwidth},g24_romaing_en=#{g24RomaingEn},g24_wmm_relate=#{g24WmmRelate},g24_roaming_threshold=#{g24Roamingthreshold},g24_clients=#{g24Clients},"
			+ "g5_en=#{g5En},g5_standard=#{g5Standard},g5_channel=#{g5Channel},g5_bandwidth=#{g5Bandwidth},g5_vht_bandwidth=#{g5VhtBandwidth},g5_romaing_en=#{g5RomaingEn},g5_wmm_relate=#{g5WmmRelate},g5_roaming_threshold=#{g5Roamingthreshold},g5_clients=#{g5Clients} where id=#{id}")
	void update(CustomRf deviceRf);
	
	@Delete("delete from custom_rf where device_id=#{deviceId}")
	void delete(@Param("deviceId") long deviceId);
	
	@Delete({"<script>",
	    "delete from custom_rf ", 
	    "WHERE ", 
	    "device_id IN", 
	      "<foreach item='item' index='index' collection='deviceIds'",
	        "open='(' separator=',' close=')'>",
	        "#{item}",
	      "</foreach>",
	"</script>"})
	void deleteByDeviceIds(@Param("deviceIds")List<Long> deviceIds);

}
